﻿<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>vue页面切换</title>

<style>
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  overflow: hidden;
  font-size: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button {
  font-family: inherit;
  font-size: inherit;
}

.page {
  overflow-y: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  padding: 50px;
  text-align: center;
}

.inner {
  margin: auto;
  height: 100%;
  width: 700px;
}

.title {
  margin-bottom: 50px;
  font-size: 48px;
}

.button-wrapper {
  margin-top: 50px;
}

.button {
  position: relative;
  height: 60px;
  width: 300px;
  background-color: transparent;
  border: 3px solid #fff;
  color: #fff;
  cursor: pointer;
  -webkit-transition: color 150ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: color 150ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
}
.button::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  background-color: #fff;
  -webkit-transform: scaleX(0);
          transform: scaleX(0);
  -webkit-transform-origin: left center;
          transform-origin: left center;
  -webkit-transition: -webkit-transform 150ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: -webkit-transform 150ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: transform 150ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: transform 150ms cubic-bezier(0.1, 0.7, 0.6, 0.9), -webkit-transform 150ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
}
.button:hover.button-start {
  color: #f1b00f;
}
.button:hover.button-next {
  color: #c598af;
}
.button:hover::before {
  -webkit-transform: scaleX(1);
          transform: scaleX(1);
}
.button-text {
  position: relative;
}

.start {
  background-color: #f1b00f;
  color: #fff;
}

.next {
  background-color: #c598af;
  color: #fff;
}
.next-list {
  list-style: disc;
  text-align: left;
  margin: auto;
  width: 430px;
  line-height: 1.6;
}

/* Transition
 -----------------------------*/
.page-enter-active {
  -webkit-transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95), -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
}
.page-enter-active .enter-1 {
  -webkit-transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  -webkit-transition-property: opacity, -webkit-transform;
  transition-property: opacity, -webkit-transform;
  transition-property: opacity, transform;
  transition-property: opacity, transform, -webkit-transform;
  -webkit-transition-delay: 520ms;
          transition-delay: 520ms;
}

.page-enter {
  -webkit-transform: translateX(100%);
          transform: translateX(100%);
}
.page-enter .enter-1 {
  opacity: 0;
  -webkit-transform: translateX(50px);
          transform: translateX(50px);
}

.page-leave-active {
  display: block;
}

.page-enter-active {
  -webkit-transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95), -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
}
.page-enter-active .enter-2 {
  -webkit-transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  -webkit-transition-property: opacity, -webkit-transform;
  transition-property: opacity, -webkit-transform;
  transition-property: opacity, transform;
  transition-property: opacity, transform, -webkit-transform;
  -webkit-transition-delay: 640ms;
          transition-delay: 640ms;
}

.page-enter {
  -webkit-transform: translateX(100%);
          transform: translateX(100%);
}
.page-enter .enter-2 {
  opacity: 0;
  -webkit-transform: translateX(50px);
          transform: translateX(50px);
}

.page-leave-active {
  display: block;
}

.page-enter-active {
  -webkit-transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95), -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
}
.page-enter-active .enter-3 {
  -webkit-transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  -webkit-transition-property: opacity, -webkit-transform;
  transition-property: opacity, -webkit-transform;
  transition-property: opacity, transform;
  transition-property: opacity, transform, -webkit-transform;
  -webkit-transition-delay: 760ms;
          transition-delay: 760ms;
}

.page-enter {
  -webkit-transform: translateX(100%);
          transform: translateX(100%);
}
.page-enter .enter-3 {
  opacity: 0;
  -webkit-transform: translateX(50px);
          transform: translateX(50px);
}

.page-leave-active {
  display: block;
}

.page-enter-active {
  -webkit-transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95), -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
}
.page-enter-active .enter-4 {
  -webkit-transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  -webkit-transition-property: opacity, -webkit-transform;
  transition-property: opacity, -webkit-transform;
  transition-property: opacity, transform;
  transition-property: opacity, transform, -webkit-transform;
  -webkit-transition-delay: 880ms;
          transition-delay: 880ms;
}

.page-enter {
  -webkit-transform: translateX(100%);
          transform: translateX(100%);
}
.page-enter .enter-4 {
  opacity: 0;
  -webkit-transform: translateX(50px);
          transform: translateX(50px);
}

.page-leave-active {
  display: block;
}

.page-enter-active {
  -webkit-transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
  transition: transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95), -webkit-transform 400ms cubic-bezier(0.4, 0.1, 0.7, 0.95);
}
.page-enter-active .enter-5 {
  -webkit-transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  transition: 300ms cubic-bezier(0.1, 0.7, 0.6, 0.9);
  -webkit-transition-property: opacity, -webkit-transform;
  transition-property: opacity, -webkit-transform;
  transition-property: opacity, transform;
  transition-property: opacity, transform, -webkit-transform;
  -webkit-transition-delay: 1000ms;
          transition-delay: 1000ms;
}

.page-enter {
  -webkit-transform: translateX(100%);
          transform: translateX(100%);
}
.page-enter .enter-5 {
  opacity: 0;
  -webkit-transform: translateX(50px);
          transform: translateX(50px);
}

.page-leave-active {
  display: block;
}
</style>
</head>
<body>

<script type="text/javascript" src="js/vue.js"></script>

<div id="app">
  <transition name="page" :duration="1300">
    <div class="page" :is="page" @change-page="onChangePage"></div>
  </transition>
</div>

<script id="start" type="text/x-template">
  <div class="start">
    <div class="inner"> 
      <h1 class="title enter-1">页面切换演示</h1>
      <div class="button-wrapper enter-2">
        <button class="button button-start" type="button" @click="$emit('change-page', 'next')"> <span class="button-text">Start!</span></button>
      </div>
    </div>
  </div>
</script>

<script id="next" type="text/x-template">
  <div class="next">
    <div class="inner">
      <h1 class="title enter-1">您可能想要使用…</h1>
      <ul class="next-list">
        <li class="enter-3">CSS Transition/Animation for simple animation combinations</li>
        <li class="enter-4">JavaScript hooks for complex animation      </li>
      </ul>
      <div class="button-wrapper enter-5">
        <button class="button button-next" type="button" @click="$emit('change-page', 'start')"><span class="button-text">Back</span></button>
      </div>
    </div>
  </div>
</script>


<script>
Vue.config.productionTip = false

Vue.component('start', {
  template: '#start'
})

Vue.component('next', {
  template: '#next'
})

new Vue({
  el: '#app',
  
  data: {
    page: 'start'
  },
  
  methods: {
    onChangePage(to) {
      this.page = to
    }
  }
})</script>

</body>
</html>
